﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using System.Data.SqlClient;
using QLKN.DataAccess;

namespace QLKN
{
    public partial class Lapkhieunai : Form
    {
        SqlConnection conn;
        SqlDataAdapter da, da1,da2;
        SqlCommand cmd, cmd1,cmd2;
        SqlCommandBuilder cmb,cmb1;
        DataSet ds, ds1,ds2;
        DataTable dt, dt1,dt2;
        public Lapkhieunai()
        {
            InitializeComponent();
        }

        private void Lapkhieunai_Load(object sender, EventArgs e)
        {
            conn = Data.getConnection();
            cmd = new SqlCommand("select a.cID, a.kID, b.kTenkhachhang, a.sID, c.sTensanpham, a.ctNgaylap, a.ctSoluong, a.ctKhuyenmai, a.ctTongtien from ChitietHoaDon a, Khachhang b,Sanpham c where a.kid = b.kid and a.sid = c.sid;",conn);
            conn.Open();
            da = new SqlDataAdapter(cmd);
            ds = new DataSet();
            da.Fill(ds, "Hoa Don");
            dgv_HoaDon.DataSource = ds.Tables["Hoa Don"];
            conn.Close();

            cmd1 = new SqlCommand("select a.dID, b.kTenkhachhang, a.sID, c.sTensanpham, a.dLydokhieunai, a.dNgaylap, d.pbTenphongban, a.dNgayhentra, e.nvTendaydu, a.dTrangthai from Donkhieunai a, Khachhang b, Sanpham c, Phongban d, Nhanvien e where a.kID= b.kID and a.sID=c.sID and a.pbID=d.pbID and a.nvID = e.nvID;", conn);
            conn.Open();
            da1 = new SqlDataAdapter(cmd1);
            ds1 = new DataSet();
            da1.Fill(ds1, "Khieu nai");
            cmb1 = new SqlCommandBuilder(da1);
            dgv_Tab2.DataSource = ds1.Tables["Khieu nai"];
            conn.Close();

            //cmd2 = new SqlCommand("SELECT * FROM")
        }
    }
}
